package cn.itsource.ymcc.domain;

import cn.hutool.core.lang.RegexPool;
import com.baomidou.mybatisplus.enums.IdType;

import java.beans.Transient;
import java.util.Date;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.activerecord.Model;
import com.baomidou.mybatisplus.annotations.TableName;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * <p>
 * 参数配置表
 * </p>
 *
 * @author maizi
 * @since 2023-05-17
 */
@TableName("t_config")
public class Config extends Model<Config> {

    public interface ConfigInsert{}
    public interface ConfigUpdate{}
    private static final long serialVersionUID = 1L;

    /**
     * 参数主键
     */
    @NotBlank(message = "当前id不能为空",groups = {ConfigUpdate.class})
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    /**
     * 参数名称,长度不能超过6位
     */
    @TableField("config_name")
    @Size(max = 6,message = "长度不能超过6位")
    @NotBlank(message = "名称不能为空")
    private String configName;

    /**
     * 手机号校验,格式不能有误
     */
    @TableField(value = "phone",exist = false)
    @Pattern(regexp = RegexPool.MOBILE,message = "手机号格式错误")
    @NotBlank(message = "手机号不能为空")
    private String phone;
    @Email(message = "邮箱格式不正确")
    @TableField(value = "phone",exist = false)
    private String email;
    /**
     * 参数键名
     * exist = false 就是标注该字段不予数据库进行字段映射
     */
    @TableField(value = "config_key",exist = true)
    //@Transient 忽略当前字段查询
    //@Transient
    private String configKey;
    /**
     * 参数键值
     */
    @TableField("config_value")
    private String configValue;
    /**
     * 系统内置（Y是 N否）
     */
    @TableField("config_type")
    private String configType;
    /**
     * 创建者
     */
    @TableField("create_by")
    private String createBy;
    /**
     * 创建时间
     */
    @TableField("create_time")
    private Date createTime;
    /**
     * 更新者
     */
    @TableField("update_by")
    private String updateBy;
    /**
     * 更新时间
     */
    @TableField("update_time")
    private Date updateTime;
    /**
     * 备注
     */
    private String remark;

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getConfigName() {
        return configName;
    }

    public void setConfigName(String configName) {
        this.configName = configName;
    }

    public String getConfigKey() {
        return configKey;
    }

    public void setConfigKey(String configKey) {
        this.configKey = configKey;
    }

    public String getConfigValue() {
        return configValue;
    }

    public void setConfigValue(String configValue) {
        this.configValue = configValue;
    }

    public String getConfigType() {
        return configType;
    }

    public void setConfigType(String configType) {
        this.configType = configType;
    }

    public String getCreateBy() {
        return createBy;
    }

    public void setCreateBy(String createBy) {
        this.createBy = createBy;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public String getUpdateBy() {
        return updateBy;
    }

    public void setUpdateBy(String updateBy) {
        this.updateBy = updateBy;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    @Override
    protected Serializable pkVal() {
        return this.id;
    }

    @Override
    public String toString() {
        return "Config{" +
        ", id=" + id +
        ", configName=" + configName +
        ", configKey=" + configKey +
        ", configValue=" + configValue +
        ", configType=" + configType +
        ", createBy=" + createBy +
        ", createTime=" + createTime +
        ", updateBy=" + updateBy +
        ", updateTime=" + updateTime +
        ", remark=" + remark +
        "}";
    }
}
